import requests
import os

# 创建icons目录（如果不存在）
if not os.path.exists('icons'):
    os.makedirs('icons')

# 定义图标URL和对应的文件名
icon_urls = {
    'apple': 'https://cdn-icons-png.flaticon.com/512/415/415733.png',
    'banana': 'https://cdn-icons-png.flaticon.com/512/3143/3143645.png',
    'cherry': 'https://cdn-icons-png.flaticon.com/512/590/590685.png',
    'strawberry': 'https://cdn-icons-png.flaticon.com/512/590/590683.png',
    'orange': 'https://cdn-icons-png.flaticon.com/512/415/415731.png',
    'grape': 'https://cdn-icons-png.flaticon.com/512/2224/2224241.png',
    'watermelon': 'https://cdn-icons-png.flaticon.com/512/874/874997.png',
    'lemon': 'https://cdn-icons-png.flaticon.com/512/415/415735.png'
}

def download_icon(url, filename):
    response = requests.get(url)
    if response.status_code == 200:
        with open(f'icons/{filename}.png', 'wb') as f:
            f.write(response.content)
        print(f"Successfully downloaded {filename}.png")
    else:
        print(f"Failed to download {filename}.png")

# 下载所有图标
for name, url in icon_urls.items():
    download_icon(url, name)

print("All icons have been downloaded.")